﻿using XamlCleaner.Core.Pharser;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Xml;

namespace XamlCleaner.Core.Test
{


    /// <summary>
    ///This is a test class for XamlPharserTest and is intended
    ///to contain all XamlPharserTest Unit Tests
    ///</summary>
    [TestClass()]
    public class XamlPharserTest
    {

        string path = @"C:\Users\Miguel\Documents\Visual Studio 2010\Projects\CodePlex\XamlCleaner\XamlCleaner.Core.Test\bin\Debug\";
        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        [TestInitialize()]
        public void MyTestInitialize()
        {
            System.IO.File.Copy(
                                string.Format("{0}OriginalTest.xaml", path),
                                string.Format("{0}Test.xaml", path),
                                true
                                );
        }

        //Use TestCleanup to run code after each test has run
        [TestCleanup()]
        public void MyTestCleanup()
        {
            System.IO.File.Delete(string.Format("{0}Test.xaml", path));
        }
        #endregion


        /// <summary>
        ///A test for Pharse
        ///</summary>
        [TestMethod()]
        public void XmlPharser_Pharse_XmlDocument()
        {
            string filePath = string.Format("{0}Test.xaml", path);
            XmlDocument xmlDocument = new XmlDocument(); // TODO: Initialize to an appropriate value
            xmlDocument.Load(filePath);

            XamlPharser target = new XamlPharser(xmlDocument); // TODO: Initialize to an appropriate value
            XmlDocument expected = new XmlDocument();
            expected.Load(string.Format("{0}NormalizedTest.xaml", path)); // TODO: Initialize to an appropriate value
            XmlDocument actual;
            actual = target.Pharse();
            Assert.AreEqual(expected.OuterXml, actual.OuterXml);
        }
    }
}
